import Mock from 'mockjs'

const BASE_URL = ''

const treeOrgNode = {
    "name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
    "id|+1": "1",
    "parentId": null,
    "type": "env",
    "children": [{
        "name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
        "id": "1_1",
        "parentId": null,
        "children": [{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_1",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_2",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_3",
            "parentId": null,
        }]
    }, {
        "name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
        "id": "1_2",
        "parentId": null,
        "children": [{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_2_1",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_2_2",
            "parentId": null,
        }]
    },{
		"name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
		"id": "2",
		"parentId": null,
		"type": "env",
		"children": [{
			"name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
			"id": "2_1",
			"parentId": null,
			"children": [{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_1",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_2",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_3",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_4",
				"parentId": null,
			}]
		}, {
			"name": /^[\u4e00-\u9fa5]{5,10}环保局$/u,
			"id": "2_2",
			"parentId": null,
			"children": [{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_2_1",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_2_2",
				"parentId": null,
			}]
		}]
	}]
}

const treeAreaNode = {
    "name": /^[\u4e00-\u9fa5]{2,3}省$/u,
    "id": "1",
    "parentId": null,
    "type": "env",
    "children": [{
        "name": /^[\u4e00-\u9fa5]{2,3}市$/u,
        "id": "1_1",
        "parentId": null,
        "children": [{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_1",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_2",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_1_3",
            "parentId": null,
        }]
    }, {
        "name": /^[\u4e00-\u9fa5]{2,3}市$/u,
        "id": "1_2",
        "parentId": null,
        "children": [{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_2_1",
            "parentId": null,
        },{
            "name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
            "id": "1_2_2",
            "parentId": null,
        }]
    },{
		"name": /^[\u4e00-\u9fa5]{2,3}省$/u,
		"id": "2",
		"parentId": null,
		"type": "env",
		"children": [{
			"name": /^[\u4e00-\u9fa5]{2,3}市$/u,
			"id": "2_1",
			"parentId": null,
			"children": [{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_1",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_2",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_3",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_1_4",
				"parentId": null,
			}]
		}, {
			"name": /^[\u4e00-\u9fa5]{2,3}市$/u,
			"id": "2_2",
			"parentId": null,
			"children": [{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_2_1",
				"parentId": null,
			},{
				"name": /^[\u4e00-\u9fa5]{5,10}有限公司$/u,
				"id": "2_2_2",
				"parentId": null,
			}]
		}]
	}]
}


const mockD = {
    "name|+1": 1,
}

// 对树进行压力测试 10000个长度的数组


export default [
    {
        url: `${BASE_URL}/Tree.asmx/CreateTree`,
        type: 'post',
        response: config => {
            const querys = config.query;
            let result = [];
            if(querys.type === 'org'){
                result = treeOrgNode
            }else if(querys.type === 'area'){
                result = treeAreaNode
            }
            return {
                code: 200,
                data: result,
            }
        }
    },
    {
        url: `${BASE_URL}/Tree.asmx/CreateTreeEnterprise`,
        type: 'post',
        response: config => {
            const querys = config.query;
            let result = [];
            if(querys.type === 'org'){
                result = treeOrgNode
            }else if(querys.type === 'area'){
                result = treeAreaNode
            }
            return {
                code: 200,
                data: result,
            }
        }
    },
]

